package work.MrSun.xyq.controller;

/**
 * @Author MrSun
 * @Date 2023/4/13 19:30
 */

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import work.MrSun.xyq.model.XyqAttend;
import work.MrSun.xyq.model.XyqUser;
import work.MrSun.xyq.service.XyqAttendService;
import work.MrSun.xyq.service.XyqCommentService;
import work.MrSun.xyq.service.XyqNewMessageService;
import work.MrSun.xyq.service.XyqUserService;
import work.MrSun.xyq.util.isComment.IsComment;

/**
 * 添加评论
 */
@RestController
public class CommentController {

    @Autowired
    private XyqUserService xyqUserService;

    @Autowired
    private XyqCommentService xyqCommentService;
    @Autowired
    private XyqNewMessageService xyqNewMessageService;

    @Autowired
    private XyqAttendService xyqAttendService;

    /**
     * 添加评论
     * @param userId
     * @param userComment
     * @param messageId
     * @param messageUserId
     * @return
     */
    @Transactional
    @PostMapping("/addComment/{userId}/{messageId}/{messageUserId}")
    public IsComment addComment(@PathVariable Integer userId,
                                @RequestBody String userComment,
                                @PathVariable Integer messageId,
                                @PathVariable Integer messageUserId) {
        return new IsComment().isTrue(userId, messageId, userComment, messageUserId,
                xyqUserService, xyqCommentService, xyqNewMessageService, xyqAttendService);
    }


}
